package com.yzc.mihuyou.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yzc.mihuyou.entity.Invitation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 帖子表 	 Mapper 接口
 * </p>
 *
 * @author 易紫诚
 * @since 2022-04-28
 */
@Mapper
public interface InvitationMapper extends BaseMapper<Invitation> {
    @Select("select * from \n" +
            "(select invitation_id, SUM(invtation_prin) as sums,SUM(invtation_ore) as zwu,count(*) as count from\n" +
            "give group by invitation_id) a, \n" +
            "(select * FROM invitation) b  ${ew.customSqlSegment}")
    List<Invitation> rowe(@Param("page")IPage<Invitation> page,@Param(Constants.WRAPPER) Wrapper<Invitation> wrapper);

    @Select("select invitation_id, SUM(invtation_prin) as sums,SUM(invtation_ore) as zwu,count(*) as count from give ${ew.customSqlSegment} group by invitation_id  ")
    Invitation rowes(@Param(Constants.WRAPPER) Wrapper<Invitation> wrapper);

    @Select("select * from \n" +
            "(select blog_id,count(*) as commentNum from comment WHERE giv_we=0 group by blog_id) a, \n" +
            "(select * FROM invitation) b  ${ew.customSqlSegment}")
    List<Invitation> rower(@Param("page")IPage<Invitation> page,@Param(Constants.WRAPPER) Wrapper<Invitation> wrapper);

    @Select("select count(*) as commentNum from comment ${ew.customSqlSegment}")
    Invitation rowesNun(@Param(Constants.WRAPPER) Wrapper<Invitation> wrapper);
}
